//
//  SocialItemCell.m
//  ShowYork
//
//  Created by hxh on 2020/9/27.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "SocialResultItemCell.h"

@interface SocialResultItemCell ()
@property (nonatomic,strong)UIImageView *imgView;
@property (nonatomic,assign)NSInteger index;
@end

@implementation SocialResultItemCell

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.imgView = [[UIImageView alloc]init];
        self.imgView.layer.masksToBounds = YES;
        self.imgView.userInteractionEnabled = YES;
        self.imgView.contentMode = UIViewContentModeScaleAspectFill;
        [self.contentView addSubview:self.imgView];
        
        [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.bottom.equalTo(self.contentView);
        }];
//        
//        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapMethod)];
//        [self.imgView addGestureRecognizer:tap];
    }
    return self;
}

- (void)setItemImage:(UIImage *)img atIndex:(NSInteger)index{
    [self.imgView setImage:img];
    self.index = index;
}

- (void)tapMethod{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectAtIndex:)]) {
        [self.delegate didSelectAtIndex:self.index];
    }
}

@end
